import { request } from "@/utils/service"
import type * as GameConfig from "./types/game-config"
import { AxiosResponse } from "axios"

/** 增 */
export function createGCDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/by_config/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteGCDataApi(id: string) {
  return request({
    url: `/toksim/resource/by_config/delete/${id}`,
    method: "post"
  })
}

/** 改 */
export function updateGCDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/by_config/edit",
    method: "post",
    data
  })
}

/** 查 */
export function getGCDataApi(params: GameConfig.PageTableRequestData) {
  return request<GameConfig.SearchGCTableResponseData>({
    url: "/toksim/resource/by_config/search",
    method: "post",
    data: params
  })
}

/** 查 */
export function getGCListApi() {
  return request<GameConfig.GCTableResponseData>({
    url: "/toksim/resource/by_config/list",
    method: "get"
  })
}

/** 根据id查询资源库信息 */
export function getGCInfoApi(id: string) {
  return request<GameConfig.GCViewInfoResponseData>({
    url: `/toksim/resource/by_config/get/${id}`,
    method: "get"
  })
}
/** 获取博弈配置类型 */
export function getGCTypeOptionsApi() {
  return request<ApiResponseData<string[]>>({
    url: `/toksim/resource/by_config/type/get`,
    method: "get"
  })
}

/** 下载博弈配置资源 */
export function downloadGCApi(id: string) {
  return request<AxiosResponse>({
    headers: {
      "Content-Type": "application/octet-stream"
    },
    responseType: "blob",
    url: `/toksim/resource/by_config/download/${id}`,
    method: "get"
  })
}
